package com.sairobo.admin.modules.srblive.service.impl;

import java.util.Map;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.sairobo.base.common.utils.Assert;
import com.sairobo.base.common.entity.Page;
import com.sairobo.base.common.entity.Query;
import com.sairobo.base.common.utils.CommonUtils;
import com.sairobo.admin.modules.srblive.entity.SrbliveUser;
import com.sairobo.admin.modules.srblive.manager.SrbliveUserManager;
import com.sairobo.admin.modules.srblive.service.SrbliveUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sairobo.base.common.entity.R;

/**
 * 用户信息
 *
 * @author admin
 * @email sairobo
 * @url www.sairobo.com
 * @date 2018年1月11日 上午11:05:49
 */
@Service("srbliveUserService")
public class SrbliveUserServiceImpl implements SrbliveUserService {

	@Autowired
	private SrbliveUserManager srbliveUserManager;

	@Override
	public Page<SrbliveUser> listSrbliveUser(Map<String, Object> params) {
		Query query = new Query(params);
		Page<SrbliveUser> page = new Page<>(query);
		srbliveUserManager.listSrbliveUser(page, query);
		return page;
	}

	@Override
	public R saveSrbliveUser(SrbliveUser role) {
		int count = srbliveUserManager.saveSrbliveUser(role);
		return CommonUtils.msg(count);
	}

	@Override
	public R getSrbliveUserById(Long id) {
		SrbliveUser srbliveUser = srbliveUserManager.getSrbliveUserById(id);
		return CommonUtils.msg(srbliveUser);
	}

	@Override
	public R updateSrbliveUser(SrbliveUser srbliveUser) {
		int count = srbliveUserManager.updateSrbliveUser(srbliveUser);
		return CommonUtils.msg(count);
	}

	@Override
	public R batchRemove(Long[] id) {
		int count = srbliveUserManager.batchRemove(id);
		return CommonUtils.msg(id, count);
	}

    @Override
    public SrbliveUser getByunionId(String unionId) {
        Assert.notNull(unionId,"unionId不能为空！");
        EntityWrapper<SrbliveUser> ew = new EntityWrapper<>();
        ew.eq("unionId",unionId);
        return srbliveUserManager.selectOne(ew);
    }
}
